package com.cpa.admin.scheduling;

import com.cpa.admin.model.UserOrderDo;
import com.cpa.admin.service.UserOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * @author zhen.zhao01
 * @CreateDate 2018/11/15
 */
@Slf4j
@Component
public class OrderScheduling {

    @Autowired
    private UserOrderService userOrderService;


    @Scheduled(cron = "0 0/1 * * * ?")
    @Transactional(rollbackFor = Exception.class)
    public void completeOrder() {
        synchronized (this) {
            userOrderService.updateUnSettleButTimeOverOrder();
        }
    }


}
